package com.liang.service.impl;/*
 *@Author: ljy
 *@Date:2021/11/6 11:39
 *
 */

import com.liang.dao.UserDao;
import com.liang.entity.User;
import com.liang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class UserServiceimpl  implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    /**
     * 如果其他bean调用这个方法,在其他bean中声明事务,那就用事务.如果其他bean没有声明事务,那就不用事务.
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<User> findAll() {
        return userDao.findAll();
    }
}
